<?php
App::uses('AppModel', 'Model');
/**
 * Emprestimo Model
 *
 * @property Projeto $Projeto
 * @property Aluno $Aluno
 * @property Autorizador $Autorizador
 * @property Usuario $Usuario
 * @property Itensemprestimo $Itensemprestimo
 */
class Emprestimo extends AppModel {
	var $situacaos = array(
		'A' => 'Pendente',
		'E' => 'Em andamento',
		'F' => 'Fechado'
	);
/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'projeto_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'É obrigatório o preenchimento do projeto',
				'allowEmpty' => false,
				'required' => true,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'aluno_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'É obrigatório o preenchimento do solicitante',
				'allowEmpty' => false,
				'required' => true,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'autorizador_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'É obrigatório o preenchimento do autorizador',
				'allowEmpty' => false,
				'required' => true,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'data_inicio' => array(
			'date' => array(
				'rule' => array('date'),
				'message' => 'Informe uma data válida',
				'allowEmpty' => false,
				'required' => true,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'data_entrega' => array(
			'date' => array(
					'rule' => array('date'),
					'message' => 'Informe uma data válida',
					'allowEmpty' => false,
					'required' => true,
					//'last' => false, // Stop validation after this rule
					//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Projeto' => array(
			'className' => 'Projeto',
			'foreignKey' => 'projeto_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Aluno' => array(
			'className' => 'Aluno',
			'foreignKey' => 'aluno_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Autorizador' => array(
			'className' => 'Usuario',
			'foreignKey' => 'autorizador_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Usuario' => array(
			'className' => 'Usuario',
			'foreignKey' => 'usuario_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'Itensemprestimo' => array(
			'className' => 'Itensemprestimo',
			'foreignKey' => 'emprestimo_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	
}
